package com.paper.entity;


import java.util.HashMap;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.achievement.entity.Subject;
import com.common.util.CombinationType;
import com.common.util.PaperType;
import com.user.entity.Teacher;

@Entity
@Table(name="t_paper")
public class Paper {
	private Long id;
	private String num;
	private String title;
	private String description;
	private Subject subject;
	private CombinationType combType;
	private PaperType paperType;
	private Teacher teacher;//组卷教师
	private Integer time;   //考试时长，分钟
	private float score;  //试卷总分
	private Map<Integer,Topics> topics = new HashMap<Integer, Topics>();
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public String getNum() {
		return num;
	}
	public String getTitle() {
		return title;
	}
	public String getDescription() {
		return description;
	}
	@ManyToOne(fetch=FetchType.EAGER)
	public Subject getSubject() {
		return subject;
	}
	public CombinationType getCombType() {
		return combType;
	}
	public PaperType getPaperType() {
		return paperType;
	}
	@ManyToOne(fetch=FetchType.EAGER)
	public Teacher getTeacher() {
		return teacher;
	}
	
	public Integer getTime() {
		return time;
	}
	@OneToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
	@JoinTable(name="t_paper_topics",inverseJoinColumns=@JoinColumn(name="topics_id"))
	@MapKeyColumn(name="topics_key")
	public Map<Integer,Topics> getTopics() {
		return topics;
	}
	
	public float getScore() {
		return score;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public void setNum(String num) {
		this.num = num;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public void setSubject(Subject subject) {
		this.subject = subject;
	}
	public void setCombType(CombinationType combType) {
		this.combType = combType;
	}
	public void setPaperType(PaperType paperType) {
		this.paperType = paperType;
	}
	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}
	public void setTopics(Map<Integer,Topics> topics) {
		this.topics = topics;
	}
	public void setTime(Integer time) {
		this.time = time;
	}
	public void setScore(float score) {
		this.score = score;
	}
	
}
